package com.tally.project.system.user.controller;

import com.tally.framework.security.utils.SecurityUtils;
import com.tally.framework.web.AjaxResult;
import com.tally.framework.web.controller.BaseController;
import com.tally.project.system.user.domain.User;
import com.tally.project.system.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户信息
 * @author soul
 */
@Api(tags = "用户信息")
@Controller
@RequestMapping("/system/user")
public class UserController extends BaseController
{
    @Resource
    private IUserService userService;

    @ApiOperation("注册用户")
    @PostMapping("/register")
    @ResponseBody
    public AjaxResult register(@RequestBody User user){
        return userService.register(user);
    }

    @ApiOperation("忘记密码")
    @PostMapping("/forget")
    @ResponseBody
    public AjaxResult forget(@RequestBody User user){
        return userService.forget(user);
    }

    @ApiOperation("用户详情")
    @GetMapping("/info")
    @ResponseBody
    public AjaxResult printUser(){
        return AjaxResult.success(SecurityUtils.getUser());
    }

}